// let baseUrl = "http://test/"
let baseUrl =  "http://122.152.225.202:8080/";
// let baseUrl = "http://127.0.0.1:8880/"
document.write("<script src=\"https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js\"></script>\n" +
    "    <script src=\"https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.js\"></script>");
Date.prototype.toLocaleString = function () {   // 重写日期函数格式化日期
    return `${this.getFullYear()}-${this.getMonth() + 1 >= 10 ? (this.getMonth() + 1) : '0' + (this.getMonth() + 1)}-${this.getDate() >= 10 ? this.getDate() : '0' + this.getDate()}
                 ${this.getHours() >= 10 ? this.getHours() : '0' + this.getHours()} : ${this.getMinutes()>=10?this.getMinutes():'0'+this.getMinutes()} : ${this.getSeconds() >= 10 ? this.getSeconds() : '0' + this.getSeconds()}`;
};
myGet = function (url,data,successFn) {
    $.ajax({
        crossDomain:true,
        //请求方式
        type : "get",
        //请求的媒体类型
        contentType: "application/json;charset=UTF-8",
        //请求地址
        url : url,

        xhrFields: {
            withCredentials: true
        },
        //数据，json字符串
        data : JSON.stringify(data),
        //请求成功
        success : successFn,
        //请求失败，包含具体的错误信息
        error : function(e){
            console.log(e.status);
            console.log(e.responseText);
        }
    });

};
myPost = function (url,data,successFn) {
    $.ajax({
        //请求方式
        type : "post",
        //请求的媒体类型
        beforeSend: function(xhr) {
            xhr.withCredentials = true;
        },
        //数据类型
        processData:false,
        //请求地址
        url : url,
        //跨域cookies
        xhrFields: {
            withCredentials: true
        },
        crossDomain: true,
        //数据，json字符串
        data : data,
        //请求成功
        success : successFn,
        //请求失败，包含具体的错误信息
        error : function(e){
            console.log(e.status);
            console.log(e.responseText);
        }
    });
};
myUP = function (url,data,successFn) {
    $.ajax({
        //请求方式
        type : "post",
        //请求的媒体类型
        //请求地址
        url : url,
        crossDomain:true,
        xhrFields: {
            withCredentials: true
        },
        contentType:false,
        processData:false,
        //数据，json字符串
        data : data,
        //请求成功
        success : successFn,
        //请求失败，包含具体的错误信息
        error : function(e){

            console.log(e.status);
            console.log(e.responseText);
        }
    });
    //封装提示弹出

};


function showAlert(self,type,msg){
    self.alertType=type;
    self.alertText = msg;
    if(type==='success'){
        if(!msg)
            self.alertText = "操作成功";

    }
    else if(type === 'error'){
        if(!msg)
            self.alertText = "操作失败";
    }
    self.alertVisible = true;
    setTimeout( ()=>{self.alertVisible=false},1000)
};
function check() {
    if(!$.cookie('mid'))
        location.href="/market/login.html";
}
function logout() {
    $.cookie('mid', null);
    location.href="/market/login.html";
}

